package com.clever.springssm.utils;

import lombok.Builder;
import lombok.Data;

import javax.xml.ws.Response;

/**
 * @author ChenWang
 * @className ResponseEntity
 * @date 2020/10/30 15:55
 * @since JDK 1.8
 */

/**
 * 构造者模式
 */
@Data
@Builder
public class ResponseEntity<T>{
    private int status;
    private String message;
    private T data;

    public static<E> ResponseEntity<E> success(E data){
        return  (ResponseEntity<E>)ResponseEntity
                .builder()
                .data(data)
                .status(InfoStatus.SUCCESS.getStatus())
                .message(InfoStatus.SUCCESS.getMessage())
                .build()
                ;
    }
    public static<E> ResponseEntity<E> error(){
        return  (ResponseEntity<E>)ResponseEntity
                .builder()
                .status(InfoStatus.SYS_ERROR.getStatus())
                .message(InfoStatus.SYS_ERROR.getMessage())
                .build()
                ;
    }
}
